var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
    })(t, e);
}, function(t, e) {
    function i() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (i.prototype = e.prototype, 
    new i());
}), a = this && this.__decorate || function(t, e, o, i) {
    var n, a = arguments.length, c = a < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) c = Reflect.decorate(t, e, o, i); else for (var p = t.length - 1; 0 <= p; p--) (n = t[p]) && (c = (a < 3 ? n(c) : 3 < a ? n(e, o, c) : n(e, o)) || c);
    return 3 < a && c && Object.defineProperty(e, o, c), c;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("ValueManager"), s = e("GameConfig"), c = e("WebManager"), l = e("LoadManager"), d = cc._decorator, u = d.ccclass, p = d.property, h = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.type = 0, t.isEffect = !0, t.eventId = "点击游戏界面左上导量", t.tag = "", t.boxSprite = null, 
        t.buttonBg = null, t.app = null, t.data = [], t.idx = 0, t;
    }
    return i(t, e), t.prototype.start = function() {
        this.setType();
    }, t.prototype.setType = function() {
        var e, t, o = this;
        s.GC.isVaild(this.tag + "_icon") || (GA.isQQ() ? GA.PA.createBlockAd && (this.boxSprite && (this.boxSprite.spriteFrame = null), 
        (e = GA.PA.createBlockAd({
            adUnitId: "bf390e054ef7ea7d0749a8c4e58a48ac",
            style: {
                left: (cc.winSize.width - this.node.width) / 2 + this.node.x,
                top: (cc.winSize.height - this.node.height) / 2 - this.node.y
            },
            size: 1,
            orientation: "landscape"
        })).onResize(function(t) {
            e.style.left = (cc.winSize.width - t.width) / 2 + o.node.x, e.style.top = (cc.winSize.height - t.height) / 2 - o.node.y;
        })) : (t = r.default.getInstance().getValue("gameIcon" + this.type)) ? this.init(t) : c.default.getInstance().redirectPoll({
            Type: this.type,
            success: function(t) {
                0 == t.data.code && (r.default.getInstance().setValue("gameIcon" + o.type, t.data.data), 
                o.init(t.data.data));
            }
        }));
    }, t.prototype.init = function(t) {
        this.data = t.map(function(t) {
            return {
                appid: t.appid,
                icon: t.icon,
                path: t.path,
                is_open_code: t.is_open_code,
                qr_code: t.qr_code,
                name: t.name
            };
        }), this.isEffect && cc.tween(this.node).repeatForever(cc.tween().to(.16, {
            angle: 8
        }).to(.16, {
            angle: -8
        }).to(.08, {
            angle: 0
        }).to(.16, {
            angle: 8
        }).to(.16, {
            angle: -8
        }).to(.08, {
            angle: 0
        }).delay(2)).start(), this.setInfo(this.data[this.idx % this.data.length], this.type), 
        this.startTimer();
    }, t.prototype.startTimer = function() {
        this.schedule(this.changeInfo, 5);
    }, t.prototype.setInfo = function(t, e) {
        var o = this;
        t && (this.app = t, this.type = e, this.app.icon && l.default.getInstance().load({
            url: this.app.icon,
            success: function(t) {
                try {
                    t instanceof cc.Texture2D ? o.buttonBg.spriteFrame = new cc.SpriteFrame(t) : cc.log(t);
                } catch (t) {}
            },
            fail: function(t) {
                cc.error(t);
            }
        }));
    }, t.prototype.changeInfo = function() {
        this.idx++, this.setInfo(this.data[this.idx % this.data.length], this.type);
    }, t.prototype.onClick = function() {
        var t = this;
        GA.PA.navigateToMiniProgram({
            pkgName: this.app.appid,
            appId: this.app.appid,
            path: this.app.path,
            success: function() {
                c.default.getInstance().sentLog(t.eventId), GA.saveRedirect(t.type, t.app.appid, t.app.path), 
                t.unschedule(t.changeInfo), t.changeInfo(), t.startTimer();
            }
        });
    }, a([ p ], t.prototype, "type", void 0), a([ p ], t.prototype, "isEffect", void 0), 
    a([ p ], t.prototype, "eventId", void 0), a([ p ], t.prototype, "tag", void 0), 
    a([ p(cc.Sprite) ], t.prototype, "boxSprite", void 0), a([ p(cc.Sprite) ], t.prototype, "buttonBg", void 0), 
    a([ u ], t);
}(cc.Component);

n.default = h;